home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
14642
/
14642.xpi
/
chrome
/
content
/
historyCalendar.js
< prev
next >
Wrap
Text File
|
2009-09-29
|
35KB
|
897 lines
/* Copyright 2009, Boomtango.com. All Rights Reserved. */
/* historyCalendar.js
* Responsible for calendar view
*/
bthistory.controllers["calendar"] = {
handleUpArrow: function(){
switch(bthistory.currDur){
case 'hour':
case 'day':
var sels = document.getElementsByClassName("selected");
var body = document.getElementById("body");
var items = document.getElementsByClassName("historyItem");
if(items.length == 0){
return;
}
if(sels.length == 0){
var node = items[items.length - 1].parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node);
} else {
var sel = sels[0];
var len = items.length;
for(var x = 0; x < len; x++){
if(sel == items[x].parentNode){
if(x > 0){
var node = items[x - 1].parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node);
}
break;
}
}
}
break;
case 'week':
var sels = document.getElementsByClassName("selected");
var body = document.getElementById("body");
var items = document.getElementsByClassName("historyItem");
if(items.length == 0){
return;
}
if(sels.length == 0){
var node = items[items.length - 1].parentNode.parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node, 30);
} else {
var sel = sels[0];
var len = items.length;
for(var x = 0; x < len; x++){
if(sel == items[x].parentNode.parentNode){
if(x > 0){
var node = items[x - 1].parentNode.parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node, 30);
}
break;
}
}
}
break;
}
},
handleDownArrow: function(){
switch(bthistory.currDur){
case 'hour':
case 'day':
var sels = document.getElementsByClassName("selected");
var body = document.getElementById("body");
var items = document.getElementsByClassName("historyItem");
if(items.length == 0){
return;
}
if(sels.length == 0){
var node = items[0].parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node);
} else {
var sel = sels[0];
var len = items.length;
for(var x = 0; x < len; x++){
if(sel == items[x].parentNode){
if(x + 1 < len){
var node = items[x + 1].parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node);
}
break;
}
}
}
break;
case 'week':
var sels = document.getElementsByClassName("selected");
var body = document.getElementById("body");
var items = document.getElementsByClassName("historyItem");
if(items.length == 0){
return;
}
if(sels.length == 0){
var node = items[0].parentNode.parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node, 30);
} else {
var sel = sels[0];
var len = items.length;
for(var x = 0; x < len; x++){
if(sel == items[x].parentNode.parentNode){
if(x + 1 < len){
var node = items[x + 1].parentNode.parentNode;
bthistory.selectNode(node);
bthistory.scrollIntoView(body, node, 30);
}
break;
}
}
}
break;
}
},
onHistoryAdd: function(dataset) {
bthistory.app.log("calender::onHistoryAdd");
if(document.getElementById("nodatafound")){
bthistory.updateView();
return;
}
var len = dataset.length;
var data = null;
for(var x =0; x < len; x++){
if(dataset[x].type == "web"){
data = dataset[x];
break;
}
}
if(data){
if(data.starttime >= bthistory._range.start &&
data.starttime <= bthistory._range.end){
switch(bthistory.currDur){
case 'hour':
var d = new Date(data.starttime);
var minutes = d.getMinutes() - d.getMinutes() % 5;
var el = document.getElementById("minute." + minutes);
this.insertElement(el, data);
break;
case 'day':
var d = new Date(data.starttime);
var el = document.getElementById("hour." + d.getHours());
this.insertElement(el, data);
break;;
case 'week':
var d = new Date(data.starttime);
var el = document.getElementById("week." + d.getDay());
this.insertWeekElement(el, data);
break;
case 'month':
var d = new Date(data.starttime);
var day = d.getDate();
var el = document.getElementById("cal." + d.getDay());
var cellwidth = el.boxObject.width;
var body = document.getElementById("body");
var rows = body.getElementsByTagName('row').length - 1;
var cellheight = Math.floor((body.boxObject.height - 20) / rows) - 20;
var cellsperrow = Math.floor(cellwidth / 20);
var cellspercol = Math.floor(cellheight / 20);
var label = document.getElementById("daywebctr." + day);
if(label.hasAttribute("numitems")){
var itemctr = 0;
} else {
var itemctr = parseInt(label.getAttribute("numitems"));
}
itemctr++;
// adjust label
if(itemctr == 1){
label.setAttribute("value", bthistory.app.getString("cal.item"));
} else {
label.setAttribute("value", bthistory.app.getString("cal.items", itemctr.toString()));
}
label.setAttribute("numitems", itemctr);
// add url if it will fit
if(itemctr <= cellspercol){
this.insertMonthElement(el, data);
// add icon if it will fit
} else if(itemctr <= cellspercol * cellsperrow){
var daystart = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0,0);
var dataset = bthistory.storage.queryTracker(
daystart.getTime(), daystart.getTime() + bthistory.ONEDAY,
bthistory.currTypes, bthistory.currFilter);
var len = el.childNodes.length;
while(len--){
el.removeChild(el.childNodes[len]);
}
this.insertMonthElements(el, day, dataset);
}
break;
}
}
}
},
onHistoryChange: function(data) {
},
handleResize: function(){
switch(bthistory.currDur){
case 'week':
case 'month':
// baby, meet bathwater
var body = document.getElementById("body");
var len = body.childNodes.length;
while(len--){
body.removeChild(body.childNodes[len]);
}
this.loadView();
break;
}
},
doResize: function(){
switch(bthistory.currDur){
case 'week':
case 'month':
var winx = document.getElementById("boomtangoHistory");
var win = {
h: winx.boxObject.height,
w: winx.boxObject.width,
x: 0,
y: 0
};
var panel = document.getElementById("rightpanel");
var body = document.getElementById("body");
var panelbox = {
h: panel.boxObject.height,
w: panel.boxObject.width,
x: panel.boxObject.x,
y: panel.boxObject.y
};
//dump("win: " + win.toSource() + "\n");
//dump("panel box: " + panelbox.toSource() + "\n");
var w = Math.max(Math.floor((body.boxObject.width -16) / 7) - 20, 50);
//dump("bodywidth: " + body.boxObject.width + ", width: " + w + "\n");
var rows = body.getElementsByTagName('row').length - 1;
var h = Math.max(Math.floor((body.boxObject.height -28) / rows) , 30);
//dump("height: " + h + "\n");
var classes = ['text-link'];
var widths = [w];
var clen = classes.length;
for(var y = 0; y < clen; y++){
var a = body.getElementsByClassName(classes[y]);
var len = a.length;
for(var x = 0; x < len; x++){
a[x].setAttribute('style', 'max-width: ' + width[y] + "px;");
}
}
var classes = ['calmonth', 'calweeklabel'];
var heights = [h,h];
var widths = [w, w];
var clen = classes.length;
for(var y = 0; y < clen; y++){
var a = body.getElementsByClassName(classes[y]);
var len = a.length;
var h = heights[y];
var w = widths[y];
for(var x = 0; x < len; x++){
if(classes[y] == 'calmonth'){
a[x].setAttribute('style', 'width: ' + w + 'px; min-height: ' + h + "px;");
} else {
a[x].setAttribute('style', 'width: ' + w + 'px;' );
}
}
}
break;
}
},
queryTracker: function(types, filter){
return bthistory.storage.queryTracker(
bthistory._range.start,
bthistory._range.end,
types,
filter
);
},
loadView: function(selectID){
this.selectID = selectID;
this.currDur = bthistory.currDur;
this.fi = Components.classes["@mozilla.org/browser/favicon-service;1"].getService(Components.interfaces.nsIFaviconService);
this.io = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService2);
var data = bthistory._data;
var len = data.length;
if(!len){
var body = document.getElementById("body");
var label= document.createElement("label");
label.id = "nodatafound";
label.setAttribute("value", bthistory.app.getString("history.nodatafound"));
label.className = "nodatafound";
body.appendChild(label);
} else {
switch(bthistory.currDur){
case 'hour':
document.loadOverlay("chrome://boomtango/content/historyCalHour.xul", this);
return;
default:
case 'day':
document.loadOverlay("chrome://boomtango/content/historyCalDay.xul", this);
return;
case 'week':
document.loadOverlay("chrome://boomtango/content/historyCalWeek.xul", this);
return;
case 'month':
document.loadOverlay("chrome://boomtango/content/historyCalMonth.xul", this);
return;
}
}
document.getElementById("bubble_back").setAttribute("hidden", "false");
},
observe: function(subject, topic, data) {
if(topic == "xul-overlay-merged"){
bthistory.app.log("historyCalendar::overlayLoaded");
this.loadMergedView();
}
},
/*
loadMergedView is handled after view has been merged.
*/
loadMergedView: function() {
switch(bthistory.currDur){
case 'hour':
this.loadHourView();
return;
default:
case 'day':
this.loadDayView();
return;
case 'week':
this.loadWeekView();
return;
case 'month':
this.loadMonthView();
return;
}
},
insertMonthElements: function(el, dayctr, items){
if(!items){
return;
}
var body = document.getElementById("body");
var cellwidth = Math.max(Math.floor((body.boxObject.width -16) / 7) - 20, 50);
var rows = body.getElementsByTagName('row').length - 1;
var cellheight = Math.floor((body.boxObject.height - 20) / rows) - 20;
var cellsperrow = Math.floor(cellwidth / 20);
var cellspercol = Math.floor(cellheight / 20);
var len = items.length;
var label = document.getElementById("daywebctr." + dayctr);
if(len == 1){
label.setAttribute("value", bthistory.app.getString("cal.item"));
} else {
label.setAttribute("value", bthistory.app.getString("cal.items", len.toString()));
}
label.setAttribute("numitems", len);
label.className = "link";
if(len <= cellspercol){
for(var x = 0; x < len; x++){
this.insertMonthElement(el, items[x]);
}
} else {
if(len > cellsperrow * cellspercol){ len = cellsperrow * cellspercol;};
var box = null;
for(var x = 0; x < len; x++){
if(!(x % cellsperrow)){
if(box){
var spacer = document.createElement("spacer");
spacer.setAttribute("flex", "1");
spacer.setAttribute("style", "background-color: transparent;");
box.appendChild(spacer);
el.appendChild(box);
}
box = document.createElement("hbox");
box.setAttribute("style", "background-color: transparent;");
}
var item = items[x];
var uri = this.io.newURI(item.url, null, null);
var iconURI = this.fi.getFaviconImageForPage(uri);
var img = document.createElement("image");
img.setAttribute("src", iconURI.spec);
img.className = "calendaricon";
img.setAttribute("style", "background-color: transparent;");
img.setAttribute("contentID", item.ftsrowid);
box.appendChild(img);
}
var spacer = document.createElement("spacer");
spacer.setAttribute("flex", "1");
spacer.setAttribute("style", "background-color: transparent;");
box.appendChild(spacer);
el.appendChild(box);
}
},
insertMonthElement: function(el, item){
var box = document.createElement('hbox');
box.setAttribute("style", "background-color: transparent;");
box.setAttribute("contentID", item.ftsrowid);
var uri = this.io.newURI(item.url, null, null);
var iconURI = this.fi.getFaviconImageForPage(uri);
var img = document.createElement("image");
img.setAttribute("src", iconURI.spec);
img.className = "calendaricon";
img.setAttribute("style", "background-color: transparent;");
var title = item.title || item.url;
var vbox = document.createElement('vbox');
vbox.setAttribute("style", "background-color: transparent;");
var linkNode = document.createElement("label");
linkNode.className = "historyItem";
//linkNode.setAttribute("href", item.url);
linkNode.setAttribute("flex", "1");
linkNode.setAttribute("value", title);
linkNode.setAttribute("crop", "end");
vbox.appendChild(linkNode);
box.appendChild(img);
box.appendChild(vbox);
el.appendChild(box);
},
insertWeekElement: function(el, item){
var box = document.createElement('hbox');
box.setAttribute("style", "background-color: transparent;");
box.setAttribute("contentID", item.ftsrowid);
var uri = this.io.newURI(item.url, null, null);
var iconURI = this.fi.getFaviconImageForPage(uri);
var img = document.createElement("image");
img.setAttribute("src", iconURI.spec);
img.className = "calendaricon";
img.setAttribute("style", "background-color: transparent;");
var title = item.title || item.url;
var vbox = document.createElement('vbox');
vbox.setAttribute("style", "background-color: transparent;");
var linkNode = document.createElement("label");
linkNode.className = "historyItem";
//linkNode.setAttribute("href", item.url);
// linkNode.setAttribute("style",
// "background-color: transparent;color:blue;");
linkNode.setAttribute("flex", "1");
linkNode.setAttribute("value", title);
linkNode.setAttribute("crop", "end");
vbox.appendChild(linkNode);
box.appendChild(img);
box.appendChild(vbox);
vbox = document.createElement('vbox');
vbox.className = "closeBox";
vbox.id = "closebox." + item.ftsrowid;
vbox.style.visibility = "hidden";
vbox.addEventListener(
"click",
function(){
bthistory.handleDeleteHistoryItem(box, item.ftsrowid);
},
false
);
img = document.createElement("image");
img.setAttribute("src", "chrome://boomtango/skin/close_icon.png");
vbox.appendChild(img);
box.appendChild(vbox);
el.appendChild(box);
},
insertElement: function(el, item, selected){
var box = document.createElement('hbox');
box.className = "calList";
box.setAttribute("style", "background-color: transparent;");
box.setAttribute("contentID", item.ftsrowid);
var uri = this.io.newURI(item.url, null, null);
var iconURI = this.fi.getFaviconImageForPage(uri);
var img = document.createElement("image");
img.setAttribute("src", iconURI.spec);
img.className = "calendaricon";
img.setAttribute("style", "background-color: transparent;");
var title = item.title || item.url;
// var vbox = document.createElement('vbox');
// vbox.setAttribute("style", "background-color: transparent;");
var linkNode = document.createElement("label");
linkNode.className = "historyItem";
//linkNode.setAttribute("href", item.url);
linkNode.setAttribute("value", title);
linkNode.setAttribute("crop", "end");
linkNode.setAttribute("flex", "1");
// vbox.appendChild(linkNode);
box.appendChild(img);
box.appendChild(linkNode);
vbox = document.createElement('vbox');
vbox.className = "closeBox";
vbox.id = "closebox." + item.ftsrowid;
vbox.style.visibility = "hidden";
vbox.addEventListener(
"click",
function(){
bthistory.handleDeleteHistoryItem(box, item.ftsrowid);
},
false
);
img = document.createElement("image");
img.setAttribute("src", "chrome://boomtango/skin/close_icon.png");
vbox.appendChild(img);
box.appendChild(vbox);
el.appendChild(box);
if(selected){
bthistory.selectNode(box);
}
},
daysInMonth: function(d){
switch(d.getMonth()){
case 3:
case 5:
case 8:
case 10:
return 30;
case 1:
return d.getFullYear() % 4 ? 28 : 29;
}
return 31;
},
loadWeekView: function() {
var firstEl = null;
var data = bthistory._data;
var len = data.length;
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var startday = bthistory._range.start;
for(var x=0; x < 7; x++){
var d = new Date(startday);
var el = document.getElementById("weeklabel." + x);
this.setWeekListener(el, d);
if(today.getTime() == d.getTime()){
var el2 = document.getElementById("week." + x);
if(x%2){
el.setAttribute("style",
"border-top: 3px solid #666;border-left: 3px solid #666;border-right: 3px solid #666; background-color: #eee;"
);
el2.setAttribute("style",
"border-bottom: 3px solid #666;border-left: 3px solid #666;border-right: 3px solid #666; background-color: #eee;"
);
} else {
el.setAttribute("style",
"border-top: 3px solid #666;border-left: 3px solid #666;border-right: 3px solid #666;"
);
el2.setAttribute("style",
"border-bottom: 3px solid #666;border-left: 3px solid #666;border-right: 3px solid #666;"
);
}
}
startday += bthistory.ONEDAY;
}
this.doResize();
for(var x=0; x < len; x++){
var item = data[x];
var d = new Date(item.starttime);
var el = document.getElementById("week." + d.getDay());
this.insertWeekElement(el, item);
if(!firstEl){
firstEl = el;
}
}
},
loadHourView: function() {
var rows = document.getElementById('minutedata');
var d = new Date(bthistory.currTime);
var hourformat = bthistory.app.getString("cal.minuteformat");
for(var x=0;x <12; x++){
var daystart = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), x * 5);
var row = document.createElement('row');
var label = document.createElement('label');
if(x){
label.setAttribute('value', daystart.toLocaleFormat(hourformat));
}
label.setAttribute('class', 'calhourlabel');
row.appendChild(label);
var vbox = document.createElement('vbox');
vbox.id = 'minute.' + (x*5);
vbox.setAttribute('class', 'calhourbox');
vbox.setAttribute('flex', '1');
if(x%2){
vbox.setAttribute('style',
'background-color: #eee;');
}
row.appendChild(vbox);
rows.appendChild(row);
}
var firstEl = null;
var data = bthistory._data;
var len = data.length;
for(var x=0; x < len; x++){
var item = data[x];
var d = new Date(item.starttime);
var minutes = d.getMinutes() - d.getMinutes() % 5;
var el = document.getElementById("minute." + minutes);
var is_selected = this.selectID && item.ftsrowid == this.selectID;
this.insertElement(el, item, is_selected);
if(!firstEl || is_selected){
firstEl = el;
}
}
var body = document.getElementById("body");
bthistory.scrollIntoView(body, firstEl);
this.selectID = null;
},
buildCell: function(el, d, dayctr, inMonth, nextMonth){
var hbox = document.createElement('hbox');
var spacer = document.createElement('spacer');
spacer.setAttribute('flex', '1');
spacer.setAttribute("style", "background-color: transparent;");
if(inMonth){
var label = document.createElement('label');
label.id = "daywebctr." + dayctr;
label.setAttribute("value", "");
label.setAttribute("style", "background-color: transparent;");
hbox.appendChild(label);
hbox.appendChild(spacer);
}
hbox.appendChild(spacer);
hbox.setAttribute("style", "background-color: transparent;");
hbox.setAttribute('flex', '1');
var p = document.createElement("label");
if(!inMonth){
p.setAttribute("class", "calmonthlabelout");
} else {
p.setAttribute("class", "calmonthlabel");
p.class = "calmonthlabel";
}
// p.setAttribute("style", "border: 1px solid blue; max-width: 30px;");
p.setAttribute('flex', '0');
p.setAttribute(
"value", dayctr
);
hbox.appendChild(p);
el.appendChild(hbox);
},
loadMonthView: function() {
var rows = document.getElementById('monthdata');
var d = new Date(bthistory.currTime);
var first = new Date(
d.getFullYear(),
d.getMonth(),
1
);
var numDays = this.daysInMonth(d);
var firstDay = first.getDay();
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var tr = document.createElement("row");
var total = firstDay + numDays;
var dayctr = 0;
var isJan = first.getMonth() == 0;
var lastMonth = new Date(
isJan ? first.getFullYear() - 1 : first.getFullYear(),
isJan ? 11 : first.getMonth() - 1,
first.getDate()
);
var lastDays = this.daysInMonth(lastMonth);
for(var x = 0; x < total; x++){
if(!(x % 7) && x){
rows.appendChild(tr);
tr = document.createElement("row");
}
var td = document.createElement("vbox");
td.className = "calmonth";
if(!firstDay){
dayctr++;
td.id = "cal." + dayctr;
this.buildCell(td, d, dayctr, true, false);
var thisday = new Date(first.getFullYear(), first.getMonth(), dayctr);
this.setMonthListener(td, thisday);
} else {
td.id = "calout.prev." + (lastDays - firstDay + 1);
var thisday = new Date(lastMonth.getFullYear(), lastMonth.getMonth(), lastDays - firstDay + 1);
this.setMonthListener(td, thisday);
this.buildCell(td, d, lastDays - firstDay + 1, false, false);
firstDay--;
}
if(!(x % 2)){
if(thisday.getTime() == today.getTime()){
td.setAttribute("style", "background-color: #eee; border: 3px solid #666;");
} else {
td.setAttribute("style", "background-color: #eee;");
}
}
tr.appendChild(td);
}
var nextMonth = 1;
var nextMonthD = new Date(
first.getMonth() == 11 ? first.getFullYear() + 1 : first.getFullYear(),
first.getMonth() == 11 ? 0 : first.getMonth() + 1,
1
);
while(total % 7){
var td = document.createElement("vbox");
td.id = "calout.next." + nextMonth;
td.className = "calmonth";
var thisday = new Date(nextMonthD.getFullYear(), nextMonthD.getMonth(),nextMonth);
this.setMonthListener(td, thisday);
this.buildCell(td, d, nextMonth++, false, true);
if(nextMonth % 2){
if(thisday.getTime() == today.getTime()){
td.setAttribute("style", "background-color: #eee; border: 3px solid #666;");
} else {
td.setAttribute("style", "background-color: #eee;");
}
}
tr.appendChild(td);
total++;
}
rows.appendChild(tr);
this.doResize();
var firstEl = null;
var data = bthistory._data;
var len = data.length;
var obj = {};
for(var x=0; x < len; x++){
var item = data[x];
var d = new Date(item.starttime);
var a = obj[d.getDate().toString()];
if(!a){
a = [];
obj[d.getDate().toString()] = a;
}
a.push(item);
if(!firstEl){
firstEl = el;
}
}
for(var x = 1; x <= numDays; x++){
var el = document.getElementById("cal." + x);
this.insertMonthElements(el, x, obj[x.toString()]);
}
var body = document.getElementById("body");
bthistory.scrollIntoView(body, firstEl);
},
setMonthListener: function(el, d){
el.addEventListener(
"click",
function(){
bthistory.currTime = d.getTime();
bthistory.loadView("calendar", "day");
},
false
);
},
setWeekListener: function(el, d){
el.addEventListener(
"click",
function(){
bthistory.currTime = d.getTime();
bthistory.loadView("calendar", "day");
},
false
);
el.addEventListener(
"mouseover",
function(){
el.style.textDecoration = "underline";
el.style.color = "blue";
},
false
);
el.addEventListener(
"mouseout",
function(){
el.style.textDecoration = "";
el.style.color = "";
},
false
);
},
setDayListener: function(el, d){
el.addEventListener(
"click",
function(){
bthistory.currTime = d.getTime();
bthistory.loadView("calendar", "hour");
},
false
);
el.addEventListener(
"mouseover",
function(){
el.style.textDecoration = "underline";
el.style.color = "blue";
},
false
);
el.addEventListener(
"mouseout",
function(){
el.style.textDecoration = "";
el.style.color = "";
},
false
);
},
loadDayView: function() {
var rows = document.getElementById('hourdata');
var d = new Date(bthistory.currTime);
// find earliest hour
var data = bthistory._data;
var len = data.length;
if(!len){
var row = document.createElement('row');
var spacer = document.createElement('spacer');
row.appendChild(spacer);
var label= document.createElement("label");
label.setAttribute("value", bthistory.app.getString("history.nodatafound"));
label.className = "nodatafound";
row.appendChild(label);
rows.appendChild(row);
return;
}
var hourformat = bthistory.app.getString("cal.hourformat");
for(var x=0;x <24; x++){
var daystart = new Date(d.getFullYear(), d.getMonth(), d.getDate(), x, 0);
var row = document.createElement('row');
var label = document.createElement('label');
label.setAttribute('value', daystart.toLocaleFormat(hourformat));
if(x == 0){
label.setAttribute("style", "margin-top: 2px;");
}
label.setAttribute('class', 'calhourlabel');
this.setDayListener(label, daystart);
row.appendChild(label);
var hbox = document.createElement('hbox');
hbox.setAttribute('flex', '1');
hbox.setAttribute('style',
'border: 1px solid red;');
var vbox = document.createElement('vbox');
vbox.id = 'hour.' + x;
vbox.setAttribute('class', 'calhourbox');
vbox.setAttribute('flex', '1');
if(x%2){
vbox.setAttribute('style',
'background-color: #eee;');
}
row.appendChild(vbox);
rows.appendChild(row);
}
var firstEl = null;
var data = bthistory._data;
var len = data.length;
for(var x=0; x < len; x++){
var item = data[x];
var d = new Date(item.starttime);
var el = document.getElementById("hour." + d.getHours());
this.insertElement(el, item);
if(!firstEl){
firstEl = el;
}
}
var body = document.getElementById("body");
bthistory.scrollIntoView(body, firstEl);
}
};